<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>类中的方法this指向</title>
</head>
<body>
  <script>
    class Person {
      constructor(name, age) {
        this.name = name
        this.age = age
      }
      study() {
        console.log(this)
      }
    }
    let p1 = new Person('tom', 18)
    p1.study()    // 通过实例调用speak方法
    const x = p1.study
    x() // undefined   p1.study是实例调用  x()是直接调用  因为类中定义的方法，已经局部开启了严格模式，所以此处指向undefined
  </script>
</body>
</html>